// -------------------用户管理-------------------
import fetch from '../config/fetch';
var pageSize = 10;

/**
 * 获取所有注册用户
 */
export const getAllInviteUser = (pageNumber, searchName, id) => fetch({
  url: '/user/v1/all',
  method: "get",
  data: { orgId: id, pageNumber: pageNumber, searchName: searchName, pageSize }
});

/**
 * 根据企业id获取所有注册用户
 */
export const getAllInviteUserById = (id, pageNumber, searchName) => fetch({
  url: '/user/v1/all',
  method: "get",
  data: { orgId: id, pageNumber: pageNumber, searchName: searchName, pageSize }
});

/**
 * 获取企业下注册用户
 */
export const getInviteUser = (pageNumber, searchName) => fetch({
  url: '/user/v1/beInviteUser',
  method: "get",
  data: { pageNumber: pageNumber, searchName: searchName, pageSize }
});

/**
 * 获取企业下购买课程的用户
 */
export const getBuyCourseUser = (pageNumber, searchName) => fetch({
  url: '/user/v1/buyCourseUser',
  method: "get",
  data: { pageNumber: pageNumber, searchName: searchName, pageSize }
});

/**
 * 获取用户已购买课程
 */
export const getUserCourse = (id) => fetch({
  url: '/coursePlan/v1/' + id,
  method: "get",
  data: {}
});

/**
 * 创建内测账号
 * params: {
  "courseId": 0,
  "pageNumber": 0,
  "pageSize": 0,
  "phones": "string"
}
 */
export const createInternalAccount = (data) => fetch({
  url: '/internalAccount/v1',
  method: "post",
  data: data
});

/**
 * 获取某一课程的所有内测账号
 */
export const getInternalAccount = (courseId, pageNumber, searchName) => fetch({
  url: '/internalAccount/v1/' + courseId,
  method: "get",
  data: { pageNumber: pageNumber, searchName: searchName, pageSize }
});

/**
 * 删除内测账号
 */
export const deleteInternalAccount = (courseId) => fetch({
  url: '/internalAccount/v1/' + courseId,
  method: "delete",
  data: {}
});

/**
 * 根据code查询企业
 */
export const selectEnterpriseByCode = (code) => fetch({
  url: '/organization/v1/inviteCode/' + code,
  method: "get",
  data: {}
});

/**
 * 修改用户归属机构
 */
export const updateCode = (endUserId, relatedOrgId) => fetch({
  url: '/user/v1/setRelatedOrgId',
  method: "put",
  data: JSON.stringify({ "endUserId": endUserId, "relatedOrgId": relatedOrgId })
});

// -------------------用户管理-------------------


// -------------------用户审核-------------------

/**
 * 获取某种状态的所有审核记录
 * params: {
 * status: 'PENDING' 'REJECTED' 'CONFIRM'
 * }
 */
export const getAllAuditing = (status, pageNumber) => fetch({
  url: '/organization/apply/v1',
  method: "get",
  data: { status: status, pageNumber: pageNumber, pageSize }
});

/**
 * 取消某一条审核
 */
export const cancelOwnerAuditing = (id) => fetch({
  url: '/organization/apply/v1/' + id + '/setStatus',
  method: "put",
  data: JSON.stringify({status: 'REJECT'})
});

/**
 * 设置某一条审核申请已经处理完成
 */
export const doneAuditing = (id) => fetch({
  url: '/organization/apply/v1/' + id + '/setStatus',
  method: "put",
  data: JSON.stringify({status: 'DONE'})
});

/**
 * 设置某一条审核申请为审核中
 */
export const progressAuditing = (id) => fetch({
  url: '/organization/apply/v1/' + id + '/setStatus',
  method: "put",
  data: JSON.stringify({status: 'PASS'})
});

/**
 * 设置某一条审核申请为审核中
 */
export const contractAuditing = (id) => fetch({
  url: '/organization/apply/v1/' + id + '/setStatus',
  method: "put",
  data: JSON.stringify({status: 'CONTRACT'})
});

/**
 * 拒绝某一条审核申请
 * params: {
 * remark: 'String' //拒绝理由
 * }
 */
export const rejectAuditing = (id, data) => fetch({
  url: '/organization/apply/v1/' + id + '/setStatus',
  method: "put",
  data: JSON.stringify(data)
});


// -------------------用户审核-------------------
